import Fields from 'dependencies/Fields'
import Field from 'dependencies/Field'

export const id = new Field({
  prop: '_id',
  label: 'orderId'
})
export const order_type = new Field({
  prop: 'order_type',
  label: '订单类型',
  type: 'select',
  enums: [
    {
      value: 'avatar',
      label: "下载头像"
    },
    {
      value: 'template',
      label: "购买模板"
    },
    {
      value: 'svip',
      label: "加入会员"
    }
  ]
})
export const pay_type = new Field({
  prop: 'pay_type',
  label: '支付渠道',
   type: 'select',
  enums:[
    {
      value: 'wxpay',
      label: "微信"
    },
    {
      value: 'ttpay',
      label: "头条"
    }
  ]
})
export const total_fee = new Field({
  prop: 'total_fee',
  label: '订单总金额'
})
export const user_id = new Field({
  prop: 'user_id',
  label: '下单用户ID'
})
export const template_id = new Field({
  prop: 'template_id',
  label: '头像模板ID'
})
export const platform = new Field({
  prop: 'platform',
  label: '下单平台',
  type: 'select',
  enums: [{
      value: 'mp-weixin',
      label: "微信"
    },
    {
      value: 'mp-toutiao',
      label: "头条"
    }
  ]
})
export const status = new Field({
  prop: 'status',
  label: '状态',
  type: 'select',
  enums: [{
        value: 1,
        label: "待付款"
      },
      {
        value: 2,
        label: "已付款"
      },
      {
        value: 3,
        label: "退款审核中"
      },
      {
        value: 4,
        label: "退款中"
      },
      {
        value: 5,
        label: "已退款"
      },
      {
        value: -1,
        label: "已取消付款"
      },
      {
        value: -2,
        label: "退款拒绝"
      }
    ]
})
export const transaction_id = new Field({
  prop: 'transaction_id',
  label: '第三方交易号'
})

export const _add_time_str = new Field({
  prop: '_add_time_str',
  label: '创建时间'
})

export const orderListFields = Object.freeze([
  id,
  order_type,
  pay_type,
  total_fee.setListComponent({
    props: {
      value: Object
    },
    render(h) {
      return h('span', '￥' + vk.pubfn.priceFilter(this.value) || '--')
    }
  }),
  user_id,
  template_id,
  status,
  transaction_id,
  platform,
  _add_time_str
])

export const queryListFields = Object.freeze([
  id,
  status,
  order_type,
  user_id
])

export const columns = [{
    key: "_id",
    title: "id",
    type: "text"
  },
  {
    key: "status",
    title: "状态",
    type: "int"
  },
  {
    key: "order_type",
    title: "order_type",
    type: "int"
  },
  {
    key: "user_id",
    title: "user_id",
    type: "int"
  }
]